unit SmallStruct.Controller.TSSControllerNavigator;

interface

uses
  Windows,
  Messages,
  SysUtils,
  Variants,
  Classes,
  Graphics,
  Controls,
  Forms,
  SmallStruct.Form.TSSPanel,
  RzBckgnd,
  ExtCtrls,
  RzPanel,
  RzBmpBtn,
  StdCtrls,
  RzLabel,
  SmallStruct.Core,
  SmallStruct.Core.TSSObjectContext,
  SmallStruct.Controller,
  SmallStruct.Core.TSSRuntimeObject;

type
  TSSControllerNavigator = class(TSSPanel, ISSControllerNavigator)
    _TopPanel: TRzPanel;
    _RightPanel: TRzPanel;
    _CloseButton: TRzBmpButton;
    _TitleLabel: TRzLabel;
  public
    procedure SetTitle(const ATitle: string; Resource: ISSObjectContainer);
    procedure OnCloseButtonClick(Sender: TObject);
    procedure InitObject; override;
  end;

  TSSControllerNavigatorContext = class(TSSObjectContext, ISSControllerNavigatorContext)
  private
    _Controller: ISSController;
  public
    function GetController: ISSController;
    procedure SetController(AController: ISSController);
  end;

implementation

{$R *.dfm}

{ TSSControllerNavigatorContext }

function TSSControllerNavigatorContext.GetController: ISSController;
begin
  Result := _Controller;
end;

procedure TSSControllerNavigatorContext.SetController(AController: ISSController);
begin
  _Controller := AController;
end;

procedure TSSControllerNavigator.InitObject;
begin
  inherited;
  _CloseButton.OnClick := OnCloseButtonClick;
end;

procedure TSSControllerNavigator.OnCloseButtonClick(Sender: TObject);
begin
  (GetContext as ISSControllerNavigatorContext).GetController.DeleteActionView((GetContext as ISSControllerNavigatorContext).GetController.GetActionActionViewName);
end;

procedure TSSControllerNavigator.SetTitle(const ATitle: string; Resource: ISSObjectContainer);
begin
  _TitleLabel.Caption := ATitle;
end;

end.
